package com.souku.finance.application.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.souku.finance.application.R;

/**
 * Created by Android on 2016/12/20.
 */

public class BanklistAdapter extends BaseAdapter {

    String[] bank_names = {"中国工商银行", "中国建设银行", "中国银行", "中国农业银行", "中国招商银行", "中国邮政银行"};

    String[] singleMoneys = {"单笔限额5万", "单笔限额5万", "单笔限额5万", "单笔限额5万", "单笔限额5万", "单笔限额5万"};

    String[] dayMoneys = {"每日限额10万", "每日限额10万", "每日限额10万", "每日限额10万", "每日限额10万", "每日限额10万"};

    int[] icons = {R.drawable.gongshang, R.drawable.jianshe, R.drawable.zhongguo, R.drawable.nongye, R.drawable.zhaoshang, R.drawable.youzheng};

    @Override
    public int getCount() {
        return 6;
    }

    @Override
    public Object getItem(int position) {
        return bank_names[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        View view = convertView;
        ViewHolder viewHolder = null;

        if (view == null || !(view.getTag() instanceof ViewHolder)) {
            view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_banklist, null);
            viewHolder = new ViewHolder(view);
            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }

        viewHolder.bankName.setText(bank_names[position]);

        viewHolder.singleMoney.setText(singleMoneys[position]);

        viewHolder.dayMoney.setText(dayMoneys[position]);

        viewHolder.ivIcon.setImageResource(icons[position]);

        return view;
    }

    static class ViewHolder {

        ImageView ivIcon;
        TextView bankName;
        TextView singleMoney;
        TextView dayMoney;

        ViewHolder(View rootView) {
            initView(rootView);
        }

        private void initView(View rootView) {
            ivIcon = (ImageView) rootView.findViewById(R.id.iv_icon);
            bankName = (TextView) rootView.findViewById(R.id.bank_name);
            singleMoney = (TextView) rootView.findViewById(R.id.single_money);
            dayMoney = (TextView) rootView.findViewById(R.id.day_money);
        }
    }
}
